package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.Travel;
import cn.wolfcode.trip.base.query.TravelQueryObject;
import cn.wolfcode.trip.base.service.ITravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("travelRelease")
public class TravelReleaseController {

    @Autowired
    private ITravelService travelService;

    /**
     * 待发布游记列表
     * @param qo
     * @param model
     * @return
     */
    @RequestMapping("list")
    public String user(@ModelAttribute("qo") TravelQueryObject qo, Model model){
        //已发布
        qo.setState(Travel.STATE_RELEASE);
        //公开
        qo.setIsPublic(true);
        //按照发布时间倒序
        qo.setOrderBy("t.releaseTime desc");
        model.addAttribute("pageInfo",travelService.queryForList(qo));
        return "travel/release";
    }
}
